home *** CD-ROM | disk | FTP | other *** search
- Path: csus.edu!csus
- From: sac46826@csus.edu (Mike Billard)
- Newsgroups: comp.lang.c++
- Subject: MSVC++4.0 compile error- help needed
- Date: Sat, 16 Mar 96 18:16:23 GMT
- Organization: California State University Sacramento
- Message-ID: <4if0if$m68@news.csus.edu>
- NNTP-Posting-Host: @u0108-p20.dialin.csus.edu
- X-Newsreader: News Xpress 2.0 Beta #0
-
- Please help! I am a very frustrated begenning C++ programmer trying to use
- MSVC++ 4.0. I am trying to follow good programming practice by declaring my
- objects and functions in a header file, but I'm having serious trouble. The
- stuff I'm doing is very simple and shown below:
-
- **** header file CTest.h****
- class CTest
- {
- private:
- int I;
- public:
- CTest();
- CTest(int ToI);
- void SetI(int ToI);
- int GetI();
- };
-
- **** Implementation file CTest.cpp ****
- #include "CTest.h"
-
- CTest::CTest(){};
- CTest::CTest(int ToI)
- {
- I = ToI;
- };
-
- void CTest::SetI(int ToI)
- {
- I = ToI;
- };
-
- int CTest::GetI()
- {
- return I;
- };
-
- **** main file Main.cpp ****
- #include "CTest.h"
- #include <iostream.h>
-
- void main()
- {
- CTest TestObj;
- TestObj.SetI(9);
- cout << TestObj.GetI();
- };
-
- This is very basic stuff, or so I thought. If I add the Main.cpp and the
- CTest.cpp to the console mode project and build it, MSVC++ runs fine, and I
- get no errors.
- However, when I create a Windows program (MDI, SDI, Dialog-based) and add the
- CTest.cpp to the project and the CTest.h to a simple dialog class that I
- create, upon building the project I receive the following message:
-
- :\Projects\test\CTest.cpp(23) : fatal error C1010: unexpected end of file
- while looking for precompiled header directive
-
- If I DO NOT add the CTest.cpp to the project, I receive the following errors:
-
- MyDlg.obj : error LNK2001: unresolved external symbol "public: void __thiscall
- CTest::SetI(int)"(?SetI@CTest@@QAEXH@Z)
- MyDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall
- CTest::CTest(void)"(??0CTest@@QAE@XZ)
-
- From what I can tell, the compiler cannot or will not find the
- #include "CTest.h" directive when I have included the cpp file. I have
- placed the two CTest files (CTest.h and CTest.cpp) in the project directory,
- added the project directory to the list of directories (under Options) and yet
- it STILL won't find the header file.
- I have tried to follow the examples of other files which are included in the
- project, such as the dialog.h and dialog.cpp (which have no problems
- building), and yet I continue to get the same error
- .
- Can someone please tell me what I'm doing wrong?!!!
-
- Before abandoning my investment and simply use Delphi 2.0, I'd like to at
- least try to figure out what my mistake is, if any. Again, I am relatively
- new to programming in C++ so I may be missing something really basic here.
- Readers should note that I am using the default factory settings that MSVC++
- uses in things like the options, environment, etc. The ONLY change I've made
- is to smart indent my right block bracket so it lines up with the code, but I
- doubt that is the cause of my problem. Further, I have downloaded and
- installed the latest patches.
-
- Your help is appreciated.
-
-
- -Mike Billard
-
- email: billardm@csus.edu
-